package com.xzlf.controller;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.Map;

@RestController
@RequestMapping("/test")
@Slf4j
public class TestController {

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("/test")
    public Object test() {
        ResponseEntity<String> exchange = restTemplate.exchange("http://www.baidu.com", HttpMethod.GET, null, String.class);
        String body = exchange.getBody();
        log.info("返回对象：{}", JSON.toJSONString(body));
        return body;

    }
}
